home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12938 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: news.sprintlink.net!datalytics!usenet
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: template classes in dll? (VC++ 4.0)
  5. Date: Fri, 22 Mar 1996 10:47:12 -0500
  6. Organization: Datalytics, Inc
  7. Message-ID: <3152CB80.4106@datalytics.com>
  8. References: <1996Mar6.133456.3709@cs.mun.ca> <313E48F6.41C67EA6@sparky.hampshire.ma.us> <4iim7m$ime@news2.ios.com>
  9. NNTP-Posting-Host: 204.62.224.71
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Vlastimil Adamovsky wrote:
  16. > Scott Reed <scott@sparky.hampshire.ma.us> wrote:
  17. > >I'm having difficulty building a VC++ 4.0 dll with template classes.
  18. > >The way I'm using the DllExport spec (actually __declspec(dllexport))
  19. > >doesn't appear to fit the syntax for template classes, i.e.
  20. > >  template <class T> class DllExport ListOf {...};
  21. > >results in a syntax error ("error C2960: template 'class' requires a
  22. > >tag-name"). I've searched the online help for hours but I can't figure
  23. > >this out. I'd really appreciate any help on this.
  24. > >        - scott
  25. > If you really insist on using templates, then try to instantaite them
  26. > in the your DLL and then you should not get any problems using it.
  27.  
  28. To instantiate a template requires the complete source code.  
  29. Thus, if a user of your DLL needs a specialization that is not 
  30. otherwise present in your DLL, they will require the source 
  31. code; the source is not exported.
  32.  
  33. If you want to make specific instantiations part of your DLL, 
  34. then you'll need to instantiate the template for specific 
  35. template parameters and export them.  I'm not certain how to do 
  36. that in VC, but there is probably help or a KB article 
  37. explaining how to do it.  Even doing this, someone may wish to 
  38. instantiate your template for some other template parameters.  
  39. Therefore, you'll need to provide the complete source code 
  40. anyway.
  41.  
  42. If you don't intend to make specific instantiations part of your 
  43. DLL, then there is nothing to export.  You just have to 
  44. distribute the complete template source code with your DLL.
  45.  
  46. Either way, the source code is visible--the one drawback to 
  47. templates.
  48.  
  49. -- 
  50. Robert Stewart        | My opinions are usually my own.
  51. Datalytics, Inc.    | stew@datalytics.com
  52.